<!DOCTYPE html>
<html>
<head>
<title>商品列表</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="css/bootstrap.css"/> 
</head>
<body>
<div class="container">

	<div class="text-right"><a class="btn btn-warning" href="goodAdd">添加商品</a></div>
	
	<br>
		
	<ul role="tablist" class="nav nav-tabs">
        <li class="active" role="presentation"><a href="goodList">全部商品</a></li>
        <li  role="presentation"><a href="goodList?type=1">今日推荐</a></li>
    </ul>
    
   
	
	<br>

	<table class="table table-bordered table-hover">

	<tr>
		<th width="3%">ID</th>
		<th width="5%">图片</th>
		<th width="10%">名称</th>
		<th width="10%">介绍</th>
		<th width="5%">规格</th>
		<th width="3%">价格</th>
		<th width="5%">类目</th>
		<th width="3%">库存</th>
		<th width="3%">销量</th>
		<th width="5%">操作</th>
	</tr>
	
	
         <tr>
         	<td><p>1</p></td>
         	<td><p><a href="../index/detail?id=1" target="_blank"><img src="../upload/1-1.jpg" width="100px"></a></p></td>
         	<td><p><a href="../index/detail?id=1" target="_blank">四川耙耙柑 酸甜甘香 柔嫩多汁</a></p></td>
         	<td><p>皮薄易剥 肉质软嫩</p></td>
         	<td><p>约500g</p></td>
         	<td><p>13</p></td>
         	<td><p>蔬菜水果</p></td>
         	<td><p>9</p></td>
         	<td><p>2</p></td>
			<td>
				<p>
					<a class="btn btn-success topDelete" href="javascript:;" type="1" goodId="1" text="加入今日推荐">移出今日推荐</a>
					
				</p>
				<a class="btn btn-info" href="goodEdit?id=1">修改</a>
				<a class="btn btn-danger" href="goodDelete?id=1">删除</a>
			</td>
       	</tr>
     
         <tr>
         	<td><p>2</p></td>
         	<td><p><a href="../index/detail?id=2" target="_blank"><img src="../upload/1-2.jpg" width="100px"></a></p></td>
         	<td><p><a href="../index/detail?id=2" target="_blank">红心火龙果</a></p></td>
         	<td><p></p></td>
         	<td><p>750g-1kg/两个</p></td>
         	<td><p>28</p></td>
         	<td><p>蔬菜水果</p></td>
         	<td><p>9</p></td>
         	<td><p>3</p></td>
			<td>
				<p>				
					<a class="btn btn-primary topSave" href="javascript:;" type="1" goodId="7" text="移出今日推荐">加入今日推荐</a>
				</p>
				<a class="btn btn-info" href="goodEdit?id=2">修改</a>
				<a class="btn btn-danger" href="goodDelete?id=2">删除</a>
			</td>
       	</tr>
     
         <tr>
         	<td><p>3</p></td>
         	<td><p><a href="../index/detail?id=3" target="_blank"><img src="../upload/1-3.jpg" width="100px"></a></p></td>
         	<td><p><a href="../index/detail?id=3" target="_blank">皇冠梨 松软多汁</a></p></td>
         	<td><p>果肉甘甜 细腻无渣</p></td>
         	<td><p>约500g</p></td>
         	<td><p>9</p></td>
         	<td><p>蔬菜水果</p></td>
         	<td><p>10</p></td>
         	<td><p>3</p></td>
			<td>
				<p>
					<a class="btn btn-success topDelete" href="javascript:;" type="1" goodId="3" text="加入今日推荐">移出今日推荐</a>
					
				</p>
				<a class="btn btn-info" href="goodEdit?id=3">修改</a>
				<a class="btn btn-danger" href="goodDelete?id=3">删除</a>
			</td>
       	</tr>
     
         <tr>
         	<td><p>4</p></td>
         	<td><p><a href="../index/detail?id=4" target="_blank"><img src="../upload/1-4.jpg" width="100px"></a></p></td>
         	<td><p><a href="../index/detail?id=4" target="_blank">西州蜜瓜</a></p></td>
         	<td><p>果肉厚质 中心橘红</p></td>
         	<td><p>约1kg-1.5kg 一个</p></td>
         	<td><p>30</p></td>
         	<td><p>蔬菜水果</p></td>
         	<td><p>6</p></td>
         	<td><p>8</p></td>
			<td>
				<p>
					<a class="btn btn-success topDelete" href="javascript:;" type="1" goodId="4" text="加入今日推荐">移出今日推荐</a>
					
				</p>
				<a class="btn btn-info" href="goodEdit?id=4">修改</a>
				<a class="btn btn-danger" href="goodDelete?id=4">删除</a>
			</td>
       	</tr>
     
         <tr>
         	<td><p>5</p></td>
         	<td><p><a href="../index/detail?id=5" target="_blank"><img src="../upload/1-5.jpg" width="100px"></a></p></td>
         	<td><p><a href="../index/detail?id=5" target="_blank">小台芒果 自然生长 生态种植</a></p></td>
         	<td><p>皮薄核小 果肉丰厚</p></td>
         	<td><p>约500g</p></td>
         	<td><p>26</p></td>
         	<td><p>蔬菜水果</p></td>
         	<td><p>6</p></td>
         	<td><p>9</p></td>
			<td>
				<p>
					<a class="btn btn-success topDelete" href="javascript:;" type="1" goodId="5" text="加入今日推荐">移出今日推荐</a>
					
				</p>
				<a class="btn btn-info" href="goodEdit?id=5">修改</a>
				<a class="btn btn-danger" href="goodDelete?id=5">删除</a>
			</td>
       	</tr>
     
     
	</table>

	<br>
	<div style='text-align:center;'>
		<a class='btn btn-info' disabled >首页</a>
		<a class='btn btn-info' disabled >上一页</a>
		<h2 style='display:inline;'>[1/8]</h2>
		<h2 style='display:inline;'>[40]</h2>
		<a class='btn btn-info' href='goodList?page=2'>下一页</a>
		<a class='btn btn-info' href='goodList?page=8'>尾页</a>
		<input type='text' class='form-control' style='display:inline;width:60px;' value=''/>
		<a class='btn btn-info' href='javascript:void(0);' onclick='location.href="goodList?page="+(this.previousSibling.value)+""'>GO</a>
	</div>
	<br>
</div>


<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(function(){
	$(document).on("click", ".topSave", function(){
		var type = $(this).attr("type");
		var goodId = $(this).attr("goodId");
		var text = $(this).attr("text");
		var old = $(this).text();
		var obj = this;
		$.post("topSave", {"goodId": goodId, "type": type}, function(data){
			if(data=="ok"){
				$(obj).text(text).attr("class", "btn btn-success topDelete").attr("text", old);
			}else{
				alert("操作失败!");
			}
		}, "text");
	});
	$(document).on("click", ".topDelete", function(){
		var type = $(this).attr("type");
		var goodId = $(this).attr("goodId");
		var text = $(this).attr("text");
		var old = $(this).text();
		var obj = this;
		$.post("topDelete", {"goodId": goodId, "type": type}, function(data){
			if(data=="ok"){
				$(obj).text(text).attr("class", "btn btn-primary topSave").attr("text", old);
			}else{
				alert("操作失败!");
			}
		}, "text");
	});
});
</script>
</body>
</html>